package com.example.weizix.base;

import java.util.ArrayList;

public abstract class BasePresenter<V extends BaseView>{
    public V view;
    private ArrayList<BaseModel> models;
    public BasePresenter(){
        initModel();
    }

    protected abstract void initModel();

    public void bindView(V view) {
        this.view = view;
    }

    public void onDestroy() {
        if (models!=null&&models.size()>0){
            for (int i = 0; i < models.size(); i++) {
                models.get(i).onDestroy();
            }
        }
        view = null;
    }
    public void addModel(BaseModel model){
        if (models==null){
            models=new ArrayList<>();
        }
        models.add(model);
    }
}
